package com.td.module.equipment.convert.acquisitioninfo;

import com.td.framework.common.pojo.PageResult;
import com.td.module.equipment.controller.admin.acquisitioninfo.vo.AcquisitionInfoCreateReqVO;
import com.td.module.equipment.controller.admin.acquisitioninfo.vo.AcquisitionInfoExcelVO;
import com.td.module.equipment.controller.admin.acquisitioninfo.vo.AcquisitionInfoRespVO;
import com.td.module.equipment.controller.admin.acquisitioninfo.vo.AcquisitionInfoUpdateReqVO;
import com.td.module.equipment.dal.dataobject.acquisitioninfo.AcquisitionInfoDO;
import com.td.module.equipment.framework.core.dto.EquipmentDataDto;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.ArrayList;
import java.util.List;

/**
 * 设备采集信息 Convert
 *
 * @author 王翔翔
 */
@Mapper
public interface AcquisitionInfoConvert {

    AcquisitionInfoConvert INSTANCE = Mappers.getMapper(AcquisitionInfoConvert.class);

    AcquisitionInfoDO convert(AcquisitionInfoCreateReqVO bean);

    AcquisitionInfoDO convert(AcquisitionInfoUpdateReqVO bean);

    AcquisitionInfoRespVO convert(AcquisitionInfoDO bean);

    List<AcquisitionInfoRespVO> convertList(List<AcquisitionInfoDO> list);

    PageResult<AcquisitionInfoRespVO> convertPage(PageResult<AcquisitionInfoDO> page);

    List<AcquisitionInfoExcelVO> convertList02(List<AcquisitionInfoDO> list);

    default List<AcquisitionInfoDO> converList03(EquipmentDataDto equipmentDataDto) {
        List<AcquisitionInfoDO> acquisitionInfoDOList = new ArrayList<>();

        equipmentDataDto.getExt().getData().stream().forEach(extData -> {
            acquisitionInfoDOList.add(
                    AcquisitionInfoDO.builder().stationId(equipmentDataDto.getExt().getStationID())
                            .monitorTime(equipmentDataDto.getExt().getMonitorTime())
                            .eKey(extData.getEKey())
                            .eNum(extData.getENum())
                            .eValue(extData.getEValue()).build()
            );
        });

        return acquisitionInfoDOList;

    }

}
